<template>
  <el-row>
    <el-col :span="10" :offset="6" >
      <el-form :label-position="right" label-width="80px">
        <el-form-item label="备案号">
          <el-input v-model="settingInfo.recordNum">
          </el-input>
          <div class="tip">此处填写你的备案号，如果没有可以不写</div>
        </el-form-item>
        <el-form-item label="日记">
          <el-input v-model="settingInfo.say">
          </el-input>
          <div class="tip">此处填写想说的话，不要太长</div>
        </el-form-item>
        <el-form-item class="center">
          <el-button type="primary" @click="submit">提交</el-button>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
</template>

<script>
import axios from "axios"
export default {
  name: "Setting",
  data() {
    return {
      settingInfo: {
        id: 1,
        recordNum: '',
        say: '',
        md5Password: null
      },
    }
  },
  mounted(){
    axios.get("/admin/selectInfo").then( (res) => {
      this.settingInfo = res.data
    })
  },
  methods: {
    submit() {
      this.settingInfo.md5Password = localStorage.getItem("password");
      axios.post("/admin/updateSetting",this.settingInfo).then( (res) => {
        if ( res.data === true){
          this.$message.success("修改成功");
        }
        else
          this.$message.error("修改失败");
      })
    }
  }
}
</script>

<style scoped>
.tip {
  color: #646a7c;
  font-size: 10px;
  font-weight: 300;
  font-family: "Droid Sans Mono";
  text-align: center;
}
.center {
  text-align: center;
}
</style>